package cm.tedu._02noticehomework.controller;

import cm.tedu._02noticehomework.mapper.NoticeMapper;
import cm.tedu._02noticehomework.pojo.dto.NoticeAddParam;
import cm.tedu._02noticehomework.pojo.entity.Notice;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

@Controller
public class NoticeController {
    @Autowired
    private NoticeMapper noticeMapper;
    @PostMapping("/v1/notice/add")
    @ResponseBody
    public String add(NoticeAddParam noticeAddParam){
        System.out.println("noticeAddParam" + noticeAddParam);
        Notice notice = new Notice();
        BeanUtils.copyProperties(noticeAddParam,notice);
        notice.setUserId(100L);
        notice.setCreateTime(new Date());
        notice.setUpdateTime(new Date());
        noticeMapper.insert(notice);
        return "新增资源成功";
    }
}
